package sistemioperativi.matrice.es3;

public class ControlloRiga extends Thread {

	private int [][]matrix;
	private int riga;
	private int x;
	private int y;
	private int contX;
	private int contY;
	private boolean ready = false;
	
	public ControlloRiga(int [][]matrix, int x, int y, int riga){
		
		this.matrix = matrix;
		this.x = x;
		this.y = y;
		this.riga = riga;
		this.contX = 0;
		this.contY = 0;
	
	}
	
	
	public int contX(){
		
		try{
			join();
		return contX;
		}catch(Exception e){};
		return -1;
	}
	
	public int contY(){
		try{
			join();
		return contY;
		}catch(Exception e){};
		return -1;
	}
	
	public void run(){
		
		for(int j = 0; j<matrix[riga].length; j++){
			if(matrix[riga][j] == x)
				this.contX++;
			if(matrix[riga][j] == y)
				this.contY++;
		}
		
		ready = true;
		
	}
	
	public boolean ready(){
		return ready;
	}
	

}
